/*
 * Created by the DBAccessor generator.
 * Programmer: Lennart Martens
 * Date: 28/07/2011
 * Time: 15:04:20
 */
package com.compomics.prioritizer.db.accessors;

import java.sql.*;
import java.io.*;
import java.util.*;
import com.compomics.util.db.interfaces.*;

/*
 * CVS information:
 *
 * $Revision: 1.4 $
 * $Date: 2007/07/06 09:41:53 $
 */

/**
 * This class is a generated accessor for the Project table.
 *
 * @author DBAccessor generator class (Lennart Martens).
 */
public class ProjectTableAccessor implements Deleteable, Retrievable, Updateable, Persistable {

	/**
	 * This variable tracks changes to the object.
	 */
	protected boolean iUpdated = false;

	/**
	 * This variable can hold generated primary key columns.
	 */
	protected Object[] iKeys = null;

	/**
	 * This variable represents the contents for the 'projectid' column.
	 */
	protected long iProjectid = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'l_project_typeid' column.
	 */
	protected long iL_project_typeid = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'l_instrumentid_proposed' column.
	 */
	protected long iL_instrumentid_proposed = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'l_instrumentid_accepted' column.
	 */
	protected long iL_instrumentid_accepted = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'l_protocolid' column.
	 */
	protected long iL_protocolid = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'l_taxonomyid' column.
	 */
	protected long iL_taxonomyid = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'l_labelid' column.
	 */
	protected long iL_labelid = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'l_userid' column.
	 */
	protected long iL_userid = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'name' column.
	 */
	protected String iName = null;


	/**
	 * This variable represents the contents for the 'description' column.
	 */
	protected String iDescription = null;


	/**
	 * This variable represents the contents for the 'priority' column.
	 */
	protected long iPriority = Long.MIN_VALUE;


	/**
	 * This variable represents the contents for the 'accepteddate' column.
	 */
	protected java.sql.Timestamp iAccepteddate = null;


	/**
	 * This variable represents the contents for the 'topprioritydate' column.
	 */
	protected java.sql.Timestamp iTopprioritydate = null;


	/**
	 * This variable represents the contents for the 'startanalysisdate' column.
	 */
	protected java.sql.Timestamp iStartanalysisdate = null;


	/**
	 * This variable represents the contents for the 'endanalysisdate' column.
	 */
	protected java.sql.Timestamp iEndanalysisdate = null;


	/**
	 * This variable represents the contents for the 'username' column.
	 */
	protected String iUsername = null;


	/**
	 * This variable represents the contents for the 'creationdate' column.
	 */
	protected java.sql.Timestamp iCreationdate = null;


	/**
	 * This variable represents the contents for the 'modificationdate' column.
	 */
	protected java.sql.Timestamp iModificationdate = null;


	/**
	 * This variable represents the key for the 'projectid' column.
	 */
	public static final String PROJECTID = "PROJECTID";

	/**
	 * This variable represents the key for the 'l_project_typeid' column.
	 */
	public static final String L_PROJECT_TYPEID = "L_PROJECT_TYPEID";

	/**
	 * This variable represents the key for the 'l_instrumentid_proposed' column.
	 */
	public static final String L_INSTRUMENTID_PROPOSED = "L_INSTRUMENTID_PROPOSED";

	/**
	 * This variable represents the key for the 'l_instrumentid_accepted' column.
	 */
	public static final String L_INSTRUMENTID_ACCEPTED = "L_INSTRUMENTID_ACCEPTED";

	/**
	 * This variable represents the key for the 'l_protocolid' column.
	 */
	public static final String L_PROTOCOLID = "L_PROTOCOLID";

	/**
	 * This variable represents the key for the 'l_taxonomyid' column.
	 */
	public static final String L_TAXONOMYID = "L_TAXONOMYID";

	/**
	 * This variable represents the key for the 'l_labelid' column.
	 */
	public static final String L_LABELID = "L_LABELID";

	/**
	 * This variable represents the key for the 'l_userid' column.
	 */
	public static final String L_USERID = "L_USERID";

	/**
	 * This variable represents the key for the 'name' column.
	 */
	public static final String NAME = "NAME";

	/**
	 * This variable represents the key for the 'description' column.
	 */
	public static final String DESCRIPTION = "DESCRIPTION";

	/**
	 * This variable represents the key for the 'priority' column.
	 */
	public static final String PRIORITY = "PRIORITY";

	/**
	 * This variable represents the key for the 'accepteddate' column.
	 */
	public static final String ACCEPTEDDATE = "ACCEPTEDDATE";

	/**
	 * This variable represents the key for the 'topprioritydate' column.
	 */
	public static final String TOPPRIORITYDATE = "TOPPRIORITYDATE";

	/**
	 * This variable represents the key for the 'startanalysisdate' column.
	 */
	public static final String STARTANALYSISDATE = "STARTANALYSISDATE";

	/**
	 * This variable represents the key for the 'endanalysisdate' column.
	 */
	public static final String ENDANALYSISDATE = "ENDANALYSISDATE";

	/**
	 * This variable represents the key for the 'username' column.
	 */
	public static final String USERNAME = "USERNAME";

	/**
	 * This variable represents the key for the 'creationdate' column.
	 */
	public static final String CREATIONDATE = "CREATIONDATE";

	/**
	 * This variable represents the key for the 'modificationdate' column.
	 */
	public static final String MODIFICATIONDATE = "MODIFICATIONDATE";




	/**
	 * Default constructor.
	 */
	public ProjectTableAccessor() {
	}

	/**
	 * This constructor allows the creation of the 'ProjectTableAccessor' object based on a set of values in the HashMap.
	 *
	 * @param	aParams	HashMap with the parameters to initialize this object with.
	 *		<i>Please use only constants defined on this class as keys in the HashMap!</i>
	 */
	public ProjectTableAccessor(HashMap aParams) {
		if(aParams.containsKey(PROJECTID)) {
			this.iProjectid = ((Long)aParams.get(PROJECTID)).longValue();
		}
		if(aParams.containsKey(L_PROJECT_TYPEID)) {
			this.iL_project_typeid = ((Long)aParams.get(L_PROJECT_TYPEID)).longValue();
		}
		if(aParams.containsKey(L_INSTRUMENTID_PROPOSED)) {
			this.iL_instrumentid_proposed = ((Long)aParams.get(L_INSTRUMENTID_PROPOSED)).longValue();
		}
		if(aParams.containsKey(L_INSTRUMENTID_ACCEPTED)) {
			this.iL_instrumentid_accepted = ((Long)aParams.get(L_INSTRUMENTID_ACCEPTED)).longValue();
		}
		if(aParams.containsKey(L_PROTOCOLID)) {
			this.iL_protocolid = ((Long)aParams.get(L_PROTOCOLID)).longValue();
		}
		if(aParams.containsKey(L_TAXONOMYID)) {
			this.iL_taxonomyid = ((Long)aParams.get(L_TAXONOMYID)).longValue();
		}
		if(aParams.containsKey(L_LABELID)) {
			this.iL_labelid = ((Long)aParams.get(L_LABELID)).longValue();
		}
		if(aParams.containsKey(L_USERID)) {
			this.iL_userid = ((Long)aParams.get(L_USERID)).longValue();
		}
		if(aParams.containsKey(NAME)) {
			this.iName = (String)aParams.get(NAME);
		}
		if(aParams.containsKey(DESCRIPTION)) {
			this.iDescription = (String)aParams.get(DESCRIPTION);
		}
		if(aParams.containsKey(PRIORITY)) {
			this.iPriority = ((Long)aParams.get(PRIORITY)).longValue();
		}
		if(aParams.containsKey(ACCEPTEDDATE)) {
			this.iAccepteddate = (java.sql.Timestamp)aParams.get(ACCEPTEDDATE);
		}
		if(aParams.containsKey(TOPPRIORITYDATE)) {
			this.iTopprioritydate = (java.sql.Timestamp)aParams.get(TOPPRIORITYDATE);
		}
		if(aParams.containsKey(STARTANALYSISDATE)) {
			this.iStartanalysisdate = (java.sql.Timestamp)aParams.get(STARTANALYSISDATE);
		}
		if(aParams.containsKey(ENDANALYSISDATE)) {
			this.iEndanalysisdate = (java.sql.Timestamp)aParams.get(ENDANALYSISDATE);
		}
		if(aParams.containsKey(USERNAME)) {
			this.iUsername = (String)aParams.get(USERNAME);
		}
		if(aParams.containsKey(CREATIONDATE)) {
			this.iCreationdate = (java.sql.Timestamp)aParams.get(CREATIONDATE);
		}
		if(aParams.containsKey(MODIFICATIONDATE)) {
			this.iModificationdate = (java.sql.Timestamp)aParams.get(MODIFICATIONDATE);
		}
		this.iUpdated = true;
	}


	/**
	 * This constructor allows the creation of the 'ProjectTableAccessor' object based on a resultset
	 * obtained by a 'select * from Project' query.
	 *
	 * @param	aResultSet	ResultSet with the required columns to initialize this object with.
	 * @exception	SQLException	when the ResultSet could not be read.
	 */
	public ProjectTableAccessor(ResultSet aResultSet) throws SQLException {
		this.iProjectid = aResultSet.getLong("projectid");
		this.iL_project_typeid = aResultSet.getLong("l_project_typeid");
		this.iL_instrumentid_proposed = aResultSet.getLong("l_instrumentid_proposed");
		this.iL_instrumentid_accepted = aResultSet.getLong("l_instrumentid_accepted");
		this.iL_protocolid = aResultSet.getLong("l_protocolid");
		this.iL_taxonomyid = aResultSet.getLong("l_taxonomyid");
		this.iL_labelid = aResultSet.getLong("l_labelid");
		this.iL_userid = aResultSet.getLong("l_userid");
		this.iName = (String)aResultSet.getObject("name");
		this.iDescription = (String)aResultSet.getObject("description");
		this.iPriority = aResultSet.getLong("priority");
		this.iAccepteddate = (java.sql.Timestamp)aResultSet.getObject("accepteddate");
		this.iTopprioritydate = (java.sql.Timestamp)aResultSet.getObject("topprioritydate");
		this.iStartanalysisdate = (java.sql.Timestamp)aResultSet.getObject("startanalysisdate");
		this.iEndanalysisdate = (java.sql.Timestamp)aResultSet.getObject("endanalysisdate");
		this.iUsername = (String)aResultSet.getObject("username");
		this.iCreationdate = (java.sql.Timestamp)aResultSet.getObject("creationdate");
		this.iModificationdate = (java.sql.Timestamp)aResultSet.getObject("modificationdate");

		this.iUpdated = true;
	}


	/**
	 * This method returns the value for the 'Projectid' column
	 * 
	 * @return	long	with the value for the Projectid column.
	 */
	public long getProjectid() {
		return this.iProjectid;
	}

	/**
	 * This method returns the value for the 'L_project_typeid' column
	 * 
	 * @return	long	with the value for the L_project_typeid column.
	 */
	public long getL_project_typeid() {
		return this.iL_project_typeid;
	}

	/**
	 * This method returns the value for the 'L_instrumentid_proposed' column
	 * 
	 * @return	long	with the value for the L_instrumentid_proposed column.
	 */
	public long getL_instrumentid_proposed() {
		return this.iL_instrumentid_proposed;
	}

	/**
	 * This method returns the value for the 'L_instrumentid_accepted' column
	 * 
	 * @return	long	with the value for the L_instrumentid_accepted column.
	 */
	public long getL_instrumentid_accepted() {
		return this.iL_instrumentid_accepted;
	}

	/**
	 * This method returns the value for the 'L_protocolid' column
	 * 
	 * @return	long	with the value for the L_protocolid column.
	 */
	public long getL_protocolid() {
		return this.iL_protocolid;
	}

	/**
	 * This method returns the value for the 'L_taxonomyid' column
	 * 
	 * @return	long	with the value for the L_taxonomyid column.
	 */
	public long getL_taxonomyid() {
		return this.iL_taxonomyid;
	}

	/**
	 * This method returns the value for the 'L_labelid' column
	 * 
	 * @return	long	with the value for the L_labelid column.
	 */
	public long getL_labelid() {
		return this.iL_labelid;
	}

	/**
	 * This method returns the value for the 'L_userid' column
	 * 
	 * @return	long	with the value for the L_userid column.
	 */
	public long getL_userid() {
		return this.iL_userid;
	}

	/**
	 * This method returns the value for the 'Name' column
	 * 
	 * @return	String	with the value for the Name column.
	 */
	public String getName() {
		return this.iName;
	}

	/**
	 * This method returns the value for the 'Description' column
	 * 
	 * @return	String	with the value for the Description column.
	 */
	public String getDescription() {
		return this.iDescription;
	}

	/**
	 * This method returns the value for the 'Priority' column
	 * 
	 * @return	long	with the value for the Priority column.
	 */
	public long getPriority() {
		return this.iPriority;
	}

	/**
	 * This method returns the value for the 'Accepteddate' column
	 * 
	 * @return	java.sql.Timestamp	with the value for the Accepteddate column.
	 */
	public java.sql.Timestamp getAccepteddate() {
		return this.iAccepteddate;
	}

	/**
	 * This method returns the value for the 'Topprioritydate' column
	 * 
	 * @return	java.sql.Timestamp	with the value for the Topprioritydate column.
	 */
	public java.sql.Timestamp getTopprioritydate() {
		return this.iTopprioritydate;
	}

	/**
	 * This method returns the value for the 'Startanalysisdate' column
	 * 
	 * @return	java.sql.Timestamp	with the value for the Startanalysisdate column.
	 */
	public java.sql.Timestamp getStartanalysisdate() {
		return this.iStartanalysisdate;
	}

	/**
	 * This method returns the value for the 'Endanalysisdate' column
	 * 
	 * @return	java.sql.Timestamp	with the value for the Endanalysisdate column.
	 */
	public java.sql.Timestamp getEndanalysisdate() {
		return this.iEndanalysisdate;
	}

	/**
	 * This method returns the value for the 'Username' column
	 * 
	 * @return	String	with the value for the Username column.
	 */
	public String getUsername() {
		return this.iUsername;
	}

	/**
	 * This method returns the value for the 'Creationdate' column
	 * 
	 * @return	java.sql.Timestamp	with the value for the Creationdate column.
	 */
	public java.sql.Timestamp getCreationdate() {
		return this.iCreationdate;
	}

	/**
	 * This method returns the value for the 'Modificationdate' column
	 * 
	 * @return	java.sql.Timestamp	with the value for the Modificationdate column.
	 */
	public java.sql.Timestamp getModificationdate() {
		return this.iModificationdate;
	}

	/**
	 * This method sets the value for the 'Projectid' column
	 * 
	 * @param	aProjectid	long with the value for the Projectid column.
	 */
	public void setProjectid(long aProjectid) {
		this.iProjectid = aProjectid;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'L_project_typeid' column
	 * 
	 * @param	aL_project_typeid	long with the value for the L_project_typeid column.
	 */
	public void setL_project_typeid(long aL_project_typeid) {
		this.iL_project_typeid = aL_project_typeid;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'L_instrumentid_proposed' column
	 * 
	 * @param	aL_instrumentid_proposed	long with the value for the L_instrumentid_proposed column.
	 */
	public void setL_instrumentid_proposed(long aL_instrumentid_proposed) {
		this.iL_instrumentid_proposed = aL_instrumentid_proposed;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'L_instrumentid_accepted' column
	 * 
	 * @param	aL_instrumentid_accepted	long with the value for the L_instrumentid_accepted column.
	 */
	public void setL_instrumentid_accepted(long aL_instrumentid_accepted) {
		this.iL_instrumentid_accepted = aL_instrumentid_accepted;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'L_protocolid' column
	 * 
	 * @param	aL_protocolid	long with the value for the L_protocolid column.
	 */
	public void setL_protocolid(long aL_protocolid) {
		this.iL_protocolid = aL_protocolid;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'L_taxonomyid' column
	 * 
	 * @param	aL_taxonomyid	long with the value for the L_taxonomyid column.
	 */
	public void setL_taxonomyid(long aL_taxonomyid) {
		this.iL_taxonomyid = aL_taxonomyid;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'L_labelid' column
	 * 
	 * @param	aL_labelid	long with the value for the L_labelid column.
	 */
	public void setL_labelid(long aL_labelid) {
		this.iL_labelid = aL_labelid;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'L_userid' column
	 * 
	 * @param	aL_userid	long with the value for the L_userid column.
	 */
	public void setL_userid(long aL_userid) {
		this.iL_userid = aL_userid;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Name' column
	 * 
	 * @param	aName	String with the value for the Name column.
	 */
	public void setName(String aName) {
		this.iName = aName;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Description' column
	 * 
	 * @param	aDescription	String with the value for the Description column.
	 */
	public void setDescription(String aDescription) {
		this.iDescription = aDescription;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Priority' column
	 * 
	 * @param	aPriority	long with the value for the Priority column.
	 */
	public void setPriority(long aPriority) {
		this.iPriority = aPriority;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Accepteddate' column
	 * 
	 * @param	aAccepteddate	java.sql.Timestamp with the value for the Accepteddate column.
	 */
	public void setAccepteddate(java.sql.Timestamp aAccepteddate) {
		this.iAccepteddate = aAccepteddate;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Topprioritydate' column
	 * 
	 * @param	aTopprioritydate	java.sql.Timestamp with the value for the Topprioritydate column.
	 */
	public void setTopprioritydate(java.sql.Timestamp aTopprioritydate) {
		this.iTopprioritydate = aTopprioritydate;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Startanalysisdate' column
	 * 
	 * @param	aStartanalysisdate	java.sql.Timestamp with the value for the Startanalysisdate column.
	 */
	public void setStartanalysisdate(java.sql.Timestamp aStartanalysisdate) {
		this.iStartanalysisdate = aStartanalysisdate;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Endanalysisdate' column
	 * 
	 * @param	aEndanalysisdate	java.sql.Timestamp with the value for the Endanalysisdate column.
	 */
	public void setEndanalysisdate(java.sql.Timestamp aEndanalysisdate) {
		this.iEndanalysisdate = aEndanalysisdate;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Username' column
	 * 
	 * @param	aUsername	String with the value for the Username column.
	 */
	public void setUsername(String aUsername) {
		this.iUsername = aUsername;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Creationdate' column
	 * 
	 * @param	aCreationdate	java.sql.Timestamp with the value for the Creationdate column.
	 */
	public void setCreationdate(java.sql.Timestamp aCreationdate) {
		this.iCreationdate = aCreationdate;
		this.iUpdated = true;
	}

	/**
	 * This method sets the value for the 'Modificationdate' column
	 * 
	 * @param	aModificationdate	java.sql.Timestamp with the value for the Modificationdate column.
	 */
	public void setModificationdate(java.sql.Timestamp aModificationdate) {
		this.iModificationdate = aModificationdate;
		this.iUpdated = true;
	}



	/**
	 * This method allows the caller to delete the data represented by this
	 * object in a persistent store.
	 *
	 * @param   aConn Connection to the persitent store.
	 */
	public int delete(Connection aConn) throws SQLException {
		PreparedStatement lStat = aConn.prepareStatement("DELETE FROM project WHERE projectid = ?");
		lStat.setLong(1, iProjectid);
		int result = lStat.executeUpdate();
		lStat.close();
		return result;
	}


	/**
	 * This method allows the caller to read data for this
	 * object from a persistent store based on the specified keys.
	 *
	 * @param   aConn Connection to the persitent store.
	 */
	public void retrieve(Connection aConn, HashMap aKeys) throws SQLException {
		// First check to see whether all PK fields are present.
		if(!aKeys.containsKey(PROJECTID)) {
			throw new IllegalArgumentException("Primary key field 'PROJECTID' is missing in HashMap!");
		} else {
			iProjectid = ((Long)aKeys.get(PROJECTID)).longValue();
		}
		// In getting here, we probably have all we need to continue. So let's...
		PreparedStatement lStat = aConn.prepareStatement("SELECT * FROM project WHERE projectid = ?");
		lStat.setLong(1, iProjectid);
		ResultSet lRS = lStat.executeQuery();
		int hits = 0;
		while(lRS.next()) {
			hits++;
			iProjectid = lRS.getLong("projectid");
			iL_project_typeid = lRS.getLong("l_project_typeid");
			iL_instrumentid_proposed = lRS.getLong("l_instrumentid_proposed");
			iL_instrumentid_accepted = lRS.getLong("l_instrumentid_accepted");
			iL_protocolid = lRS.getLong("l_protocolid");
			iL_taxonomyid = lRS.getLong("l_taxonomyid");
			iL_labelid = lRS.getLong("l_labelid");
			iL_userid = lRS.getLong("l_userid");
			iName = (String)lRS.getObject("name");
			iDescription = (String)lRS.getObject("description");
			iPriority = lRS.getLong("priority");
			iAccepteddate = (java.sql.Timestamp)lRS.getObject("accepteddate");
			iTopprioritydate = (java.sql.Timestamp)lRS.getObject("topprioritydate");
			iStartanalysisdate = (java.sql.Timestamp)lRS.getObject("startanalysisdate");
			iEndanalysisdate = (java.sql.Timestamp)lRS.getObject("endanalysisdate");
			iUsername = (String)lRS.getObject("username");
			iCreationdate = (java.sql.Timestamp)lRS.getObject("creationdate");
			iModificationdate = (java.sql.Timestamp)lRS.getObject("modificationdate");
		}
		lRS.close();
		lStat.close();
		if(hits>1) {
			throw new SQLException("More than one hit found for the specified primary keys in the 'project' table! Object is initialized to last row returned.");
		} else if(hits == 0) {
			throw new SQLException("No hits found for the specified primary keys in the 'project' table! Object is not initialized correctly!");
		}
	}
	/**
	 * This method allows the caller to obtain a basic select for this table.
	 *
	 * @return   String with the basic select statement for this table.
	 */
	public static String getBasicSelect(){
		return "select * from project";
	}

	/**
	 * This method allows the caller to obtain all rows for this
	 * table from a persistent store.
	 *
	 * @param   aConn Connection to the persitent store.
	 * @return   ArrayList<ProjectTableAccessor>   with all entries for this table.
	 */
	public static ArrayList<ProjectTableAccessor> retrieveAllEntries(Connection aConn) throws SQLException {
		ArrayList<ProjectTableAccessor>  entities = new ArrayList<ProjectTableAccessor>();
		Statement stat = aConn.createStatement();
		ResultSet rs = stat.executeQuery(getBasicSelect());
		while(rs.next()) {
			entities.add(new ProjectTableAccessor(rs));
		}
		rs.close();
		stat.close();
		return entities;
	}



	/**
	 * This method allows the caller to update the data represented by this
	 * object in a persistent store.
	 *
	 * @param   aConn Connection to the persitent store.
	 */
	public int update(Connection aConn) throws SQLException {
		if(!this.iUpdated) {
			return 0;
		}
		PreparedStatement lStat = aConn.prepareStatement("UPDATE project SET projectid = ?, l_project_typeid = ?, l_instrumentid_proposed = ?, l_instrumentid_accepted = ?, l_protocolid = ?, l_taxonomyid = ?, l_labelid = ?, l_userid = ?, name = ?, description = ?, priority = ?, accepteddate = ?, topprioritydate = ?, startanalysisdate = ?, endanalysisdate = ?, username = ?, creationdate = ?, modificationdate = CURRENT_TIMESTAMP WHERE projectid = ?");
		lStat.setLong(1, iProjectid);
		lStat.setLong(2, iL_project_typeid);
		lStat.setLong(3, iL_instrumentid_proposed);
		lStat.setLong(4, iL_instrumentid_accepted);
		lStat.setLong(5, iL_protocolid);
		lStat.setLong(6, iL_taxonomyid);
		lStat.setLong(7, iL_labelid);
		lStat.setLong(8, iL_userid);
		lStat.setObject(9, iName);
		lStat.setObject(10, iDescription);
		lStat.setLong(11, iPriority);
		lStat.setObject(12, iAccepteddate);
		lStat.setObject(13, iTopprioritydate);
		lStat.setObject(14, iStartanalysisdate);
		lStat.setObject(15, iEndanalysisdate);
		lStat.setObject(16, iUsername);
		lStat.setObject(17, iCreationdate);
		lStat.setLong(18, iProjectid);
		int result = lStat.executeUpdate();
		lStat.close();
		this.iUpdated = false;
		return result;
	}


	/**
	 * This method allows the caller to insert the data represented by this
	 * object in a persistent store.
	 *
	 * @param   aConn Connection to the persitent store.
	 */
	public int persist(Connection aConn) throws SQLException {
		PreparedStatement lStat = aConn.prepareStatement("INSERT INTO project (projectid, l_project_typeid, l_instrumentid_proposed, l_instrumentid_accepted, l_protocolid, l_taxonomyid, l_labelid, l_userid, name, description, priority, accepteddate, topprioritydate, startanalysisdate, endanalysisdate, username, creationdate, modificationdate) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_USER, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
		if(iProjectid == Long.MIN_VALUE) {
			lStat.setNull(1, 4);
		} else {
			lStat.setLong(1, iProjectid);
		}
		if(iL_project_typeid == Long.MIN_VALUE) {
			lStat.setNull(2, 4);
		} else {
			lStat.setLong(2, iL_project_typeid);
		}
		if(iL_instrumentid_proposed == Long.MIN_VALUE) {
			lStat.setNull(3, 4);
		} else {
			lStat.setLong(3, iL_instrumentid_proposed);
		}
		if(iL_instrumentid_accepted == Long.MIN_VALUE) {
			lStat.setNull(4, 4);
		} else {
			lStat.setLong(4, iL_instrumentid_accepted);
		}
		if(iL_protocolid == Long.MIN_VALUE) {
			lStat.setNull(5, 4);
		} else {
			lStat.setLong(5, iL_protocolid);
		}
		if(iL_taxonomyid == Long.MIN_VALUE) {
			lStat.setNull(6, 4);
		} else {
			lStat.setLong(6, iL_taxonomyid);
		}
		if(iL_labelid == Long.MIN_VALUE) {
			lStat.setNull(7, 4);
		} else {
			lStat.setLong(7, iL_labelid);
		}
		if(iL_userid == Long.MIN_VALUE) {
			lStat.setNull(8, 4);
		} else {
			lStat.setLong(8, iL_userid);
		}
		if(iName == null) {
			lStat.setNull(9, -1);
		} else {
			lStat.setObject(9, iName);
		}
		if(iDescription == null) {
			lStat.setNull(10, -1);
		} else {
			lStat.setObject(10, iDescription);
		}
		if(iPriority == Long.MIN_VALUE) {
			lStat.setNull(11, 4);
		} else {
			lStat.setLong(11, iPriority);
		}
		if(iAccepteddate == null) {
			lStat.setNull(12, 93);
		} else {
			lStat.setObject(12, iAccepteddate);
		}
		if(iTopprioritydate == null) {
			lStat.setNull(13, 93);
		} else {
			lStat.setObject(13, iTopprioritydate);
		}
		if(iStartanalysisdate == null) {
			lStat.setNull(14, 93);
		} else {
			lStat.setObject(14, iStartanalysisdate);
		}
		if(iEndanalysisdate == null) {
			lStat.setNull(15, 93);
		} else {
			lStat.setObject(15, iEndanalysisdate);
		}
		int result = lStat.executeUpdate();

		// Retrieving the generated keys (if any).
		ResultSet lrsKeys = lStat.getGeneratedKeys();
		ResultSetMetaData lrsmKeys = lrsKeys.getMetaData();
		int colCount = lrsmKeys.getColumnCount();
		iKeys = new Object[colCount];
		while(lrsKeys.next()) {
			for(int i=0;i<iKeys.length;i++) {
				iKeys[i] = lrsKeys.getObject(i+1);
			}
		}
		lrsKeys.close();
		lStat.close();
		// Verify that we have a single, generated key.
		if(iKeys != null && iKeys.length == 1 && iKeys[0] != null) {
			// Since we have exactly one key specified, and only
			// one Primary Key column, we can infer that this was the
			// generated column, and we can therefore initialize it here.
			iProjectid = ((Number) iKeys[0]).longValue();
		}
		this.iUpdated = false;
		return result;
	}

	/**
	 * This method will return the automatically generated key for the insert if 
	 * one was triggered, or 'null' otherwise.
	 *
	 * @return	Object[]	with the generated keys.
	 */
	public Object[] getGeneratedKeys() {
		return this.iKeys;
	}

}